package T4;

import java.util.Scanner;


    public class Xy {
        public static void main(String[] args) {
            System.out.println("请选择运算符：1、加法，2、减法，3、乘法，4、除法：");
            Scanner sc=new Scanner(System.in);
            Integer operator=sc.nextInt();
            System.out.println("输入第一个数字：");
            Double a=sc.nextDouble();
            System.out.println("请输入第二个数字：");
            Double b=sc.nextDouble();
            Calcuator calcuator=null;
            switch(operator){
                case 1:
                 calcuator=new Add();
                    break;
                case 2:
                    calcuator=new Sub();
                    break;
                case 3:
                    calcuator=new Mul();
                    break;
                case 4:
                    calcuator=new Div();
                    break;
            }
            calcuator.setA(a);

            calcuator.setB(b);
            System.out.println("计算结果是："+calcuator.getResult());


        }
    }
